package letcode2379

func MinimumRecolors(blocks string, k int) int {

	ans, tmp := len(blocks)+1, 0
	for right, _ := range blocks {
		if blocks[right] == 'W' {
			tmp++
		}

		if right < k-1 {
			continue
		}

		if right > k-1 {
			out := right - k
			if blocks[out] == 'W' {
				tmp--
			}
		}

		ans = min(ans, tmp)
	}

	return ans
}
